# -*- coding: utf-8 -*-
# @Time     : 2021/11/28 13:10
# @Author   : wljess
# @File     : 内置缓存模块.py
# @Describe : 
# @Software : PyCharm

#!/usr/bin/env python3
# -*- coding: UTF-8 -*-


import time
from functools import lru_cache


class Model:

    @lru_cache(maxsize=10)
    def calculate(self, number):
        print(f'calculate({number}) is  running,', end=' ')
        print('sleep  3s  ')
        time.sleep(3)

        return number * 3


if __name__ == '__main__':

    model = Model()

    for i in range(5):
        print(model.calculate(i))

    for i in range(5):
        print(model.calculate(i))
